<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>AI简历分析</title>
    <style>
        body { font-family: Arial, sans-serif; margin: 40px; background-color: #f5f5f5; }
        .container { max-width: 800px; margin: 0 auto; background: white; padding: 30px; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
        h1 { color: #333; text-align: center; }
        .upload-form { margin: 20px 0; }
        .file-input { margin: 10px 0; padding: 10px; border: 2px dashed #ccc; border-radius: 5px; }
        .btn { background: #007bff; color: white; padding: 10px 20px; border: none; border-radius: 5px; cursor: pointer; }
        .btn:hover { background: #0056b3; }
        .error { color: red; margin: 10px 0; }

        /* 导航栏样式 */
        .navbar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 30px;
            padding-bottom: 15px;
            border-bottom: 1px solid #eee;
        }
        .user-info {
            display: flex;
            align-items: center;
            gap: 15px;
            position: relative;
        }
        .user-dropdown {
            position: relative;
            display: inline-block;
        }
        .user-dropdown-btn {
            background: transparent;
            width: 40px;
            height: 40px;
            border: none;
            border-radius: 50%;
            cursor: pointer;
            padding: 0;
            overflow: hidden;
        }
        .user-avatar-img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
        .user-dropdown-content {
            display: none;
            position: absolute;
            right: 0;
            background-color: white;
            min-width: 160px;
            box-shadow: 0 8px 16px rgba(0,0,0,0.1);
            border-radius: 5px;
            z-index: 1000;
            margin-top: 5px;
        }
        .user-dropdown-content a {
            color: #333;
            padding: 12px 16px;
            text-decoration: none;
            display: block;
            border-bottom: 1px solid #eee;
        }
        .user-dropdown-content a:hover {
            background-color: #f8f9fa;
        }
        .user-dropdown:hover .user-dropdown-content {
            display: block;
        }
        .user-avatar {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            background-color: #007bff;
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
        }
        .default-avatar {
            width: 100%;
            height: 100%;
            background-color: #28a745;
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
        }
    </style>
</head>
<body>
<div class="container">
    <!-- 导航栏 -->
    <div class="navbar">
        <h1>AI简历分析系统</h1>
        <div class="user-info">
            <span th:if="${session.user}" th:text="'欢迎, ' + ${session.user.email}"></span>
            <div class="user-dropdown">
                <button class="user-dropdown-btn" title="用户管理">
                    <!-- 如果有用户头像则显示图片，否则显示首字母 -->
                    <div th:if="${session.user?.avatarUrl}" class="user-avatar-img">
                        <img th:src="${session.user.avatarUrl}" alt="用户头像" onerror="this.onerror=null;this.src='/images/img_01.png';">
                    </div>
                    <div th:unless="${session.user?.avatarUrl}" class="default-avatar"
                         th:text="${session.user?.email?.substring(0,1)?.toUpperCase()}"></div>
                </button>
                <div class="user-dropdown-content">
                    <a th:href="@{/profile}">个人资料</a>
                    <a th:href="@{/logout}">退出登录</a>
                </div>
            </div>
        </div>
    </div>

    <p>上传您的简历文件（PDF或Word格式），AI将为您提供详细的分析报告</p>

    <form class="upload-form" th:action="@{/analyze}" method="post" enctype="multipart/form-data">
        <div class="file-input">
            <input type="file" name="resumeFile" accept=".pdf,.docx" required>
        </div>
        <button type="submit" class="btn">开始分析</button>
    </form>

    <div th:if="${error}" class="error" th:text="${error}"></div>
</div>
</body>
</html>